
import org.osflash.zeroi.logging.LoggerClass;
import org.osflash.zeroi.logging.publisher.Publisher;

import LuminicBox.Log.ConsolePublisher;
import LuminicBox.Log.Logger;
 
class org.osflash.zeroi.logging.publisher.LuminicPublisher 
	implements 
		Publisher
{
	
	private static var initialized:Boolean = initialize();
	
	private static function initialize():Boolean{
		if( initialized) return true;
		
		var id:Number;
		id = setInterval( function(){
			if( LoggerClass == undefined) return;
			if( LuminicBox.Log.Logger == undefined) return;
			if( LuminicBox.Log.ConsolePublisher == undefined) return;
			//
			clearInterval( id);
			LoggerClass.getInstance().addListener( new LuminicPublisher());			
		}, 100);
	} 
	
	


	private var luminicLogger:Logger;  
	
	public function LuminicPublisher(){
		luminicLogger = new Logger("zeroi");
		luminicLogger.addPublisher( new ConsolePublisher());
		//t race("d LuminicPublisher " + [Logger, luminicLogger.debug]);
		LoggerClass.getInstance().replayHistory(this); 
	}
	
	public function publish( type:String, message:String):Void {
		luminicLogger[type](message);
	}
	
	public function toString():String{
		return "[object LuminicPublisher]";
	}
	
}